import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Method {
    private List<Record> records;

    public Method() {
        records = new ArrayList<>();
    }
    public void addIncome() {
        Scanner scanner = new Scanner(System.in);
        System.out.print("请输入日期 (YYYY-MM-DD): ");
        String date = scanner.nextLine();

        double amount=-1;
        while (amount<=0) {
            System.out.print("请输入金额: ");
            amount = scanner.nextDouble();
            if (amount <= 0) {
                System.out.println("金额必须为正数，请重新输入。");
            }
        }
        System.out.print("请输入类别: ");
        String category = scanner.next();
        System.out.print("请输入备注: ");
        String remark = scanner.next();

        records.add(new Record(date, amount, category, remark));
        System.out.println("收入记录添加成功！");
    }

    public void addExpense() {
        Scanner scanner=new Scanner(System.in);
        System.out.print("请输入日期 (YYYY-MM-DD): ");
        String date = scanner.nextLine();

        double amount=-1;
        while (amount<=0) {
            System.out.print("请输入金额 (正数): ");
            amount=scanner.nextDouble();
            if (amount<=0) {
                System.out.println("金额必须为正数，请重新输入。");
            }
        }
        System.out.print("请输入类别: ");
        String category=scanner.next();
        System.out.print("请输入备注: ");
        String remark=scanner.next();

        records.add(new Record(date, -amount, category, remark));
        System.out.println("支出记录添加成功！");
    }
}
